package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetMealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/setmeal")
@Api(tags = "套餐管理接口")
public class SetMealController {
    @Autowired
    private SetMealService setMealService;

    /**
     * 获取所有套餐信息
     */
    @GetMapping("/getSetmeal")
    @ApiOperation("获取所有套餐信息")
    public Result getSetmeal() {
        log.info("获取所有套餐信息");
        List<Setmeal> list = setMealService.getSetmeal();
        return new Result(true, MessageConstant.GET_SETMEAL_COUNT_REPORT_SUCCESS,list);
    }
    /**
     * 根据套餐id查询套餐详情，包含（套餐基本信息、套餐关联的检查组、检查组关联的检查项）
     */
    @PostMapping("/findById")
    @ApiOperation("根据套餐id查询套餐详情，包含（套餐基本信息、套餐关联的检查组、检查组关联的检查项）")
    public Result findById(@RequestParam Integer id) {
        log.info("根据套餐id查询套餐详情，包含（套餐基本信息、套餐关联的检查组、检查组关联的检查项）");
        Setmeal setmeal = setMealService.findById(id);
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
    }
}
